/*
 * Copyright 2011-2011 Tiago da Fonseca Frazao  All rights reserved.
 */

package mz.co.research.shared.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;

/**
 * @author Tiago da Fonseca Frazao
 */
@MappedSuperclass
public abstract class CreatableEntity extends LifeCycleEntity {

	@NotNull
	@Column(name = "CREATED_BY", nullable = false)
	private Long createdBy;

	@NotNull
	@Column(name = "CREATION_DATE", nullable = false)
	private Date creationDate;

	@NotNull
	@Column(name = "IP", length = 15, nullable = false)
	private String ip;

	/**
	 * @return the createdBy
	 */

	public Long getCreatedBy() {
		return createdBy;
	}

	/**
	 * @param createdBy
	 *            the createdBy to set
	 */

	public void setCreatedBy(Long createdBy) {
		this.createdBy = createdBy;
	}

	/**
	 * @return the creationDate
	 */

	public Date getCreationDate() {
		return creationDate;
	}

	/**
	 * @param creationDate
	 *            the creationDate to set
	 */

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	/**
	 * @return the ip
	 */
	public String getIp() {
		return ip;
	}

	/**
	 * @param ip
	 *            the ip to set
	 */
	public void setIp(String ip) {
		this.ip = ip;
	}

	@Override
	public String toString() {
		StringBuilder buffer = new StringBuilder("\nCreatableEntity");

		buffer.append(super.toString());

		buffer.append("\ncreatedBy    :" + this.createdBy);
		buffer.append("\ncreationDate :" + this.creationDate);

		return buffer.toString();
	}
}
